﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WorkflowCore.Service.Dto.Input
{
    /// <summary>
    /// 定义流程输入参数
    /// </summary>
    public class WorkflowDefinitionInput
    {
        /// <summary>
        /// 流程定义ID
        /// </summary>
        [Required]
        public string WorkflowDefinitionId { get; set; } = null!;
        /// <summary>
        /// 流程模板标题
        /// </summary>
        [Required]
        public string Title { get; set; } = null!;

        public int Version { get; set; } = 1;

        /// <summary>   
        /// 执行步骤
        /// </summary>
        public List<WorkflowStepNodeInput> Steps { get; set; }
    }

    public class WorkflowStepNodeInput
    {
        /// <summary>
        /// 步骤Id
        /// </summary>
        [Required]
        public string StepId { get; set; } = null!;

        /// <summary>
        /// 步骤名称
        /// </summary>
        [Required]
        public string StepName { get; set; } = null!;

        /// <summary>
        /// 下一步骤Id
        /// </summary>
        public string? NextStepId { get; set; }

        /// <summary>
        /// 步骤详情
        /// </summary>
        public WorkflowStepNodeDetail? Detail { get; set; }

        /// <summary>
        /// 节点审批类型：1：人员审批， 2：角色审批，3：If判断节点
        /// </summary>
        public StepBodyAuditTypeEnum AuditType { get; set; }
    }


    /// <summary>
    /// 工作流详细步骤信息
    /// </summary>
    public class WorkflowStepNodeDetail
    {
        /// <summary>
        /// 会签规则 1-全部审批通过 2-半数审批通过 3-任意一个审批通过 (单签审批时该属性无效)
        /// </summary>
        public HandleCountersignTypeEnum HandleCountersignType { get; set; }

        /// <summary>
        /// 审批人列表（AuditType如果是角色，则此属性存放的是角色ID）
        /// </summary>
        public List<long> AuditPersons { get; set; }
    }

    /// <summary>
    /// 节点审批类型：1：人员审批， 2：角色审批,3：If判断节点
    /// </summary>
    public enum StepBodyAuditTypeEnum
    {
        Person = 1,
        Role = 2,
        If = 3,
    }

    /// <summary>
    /// 会签规则枚举
    /// </summary>
    public enum HandleCountersignTypeEnum
    {
        /// <summary>
        /// 未知
        /// </summary>
        UnKnow = 0,
        /// <summary>
        /// 必须全部通过
        /// </summary>
        All = 1,
        /// <summary>
        /// 超过半数通过
        /// </summary>
        Half = 2,
        /// <summary>
        /// 任意一个通过
        /// </summary>
        AnyOne = 3
    }
}
